import Cookies from 'js-cookie'

const TokenKey = 'vue_token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  // 5 小时过期
  return Cookies.set(TokenKey, token, { expires: 20 / 1440 })
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setUsername(username) {
  return window.localStorage.setItem('username', username)
}

export function getUsername() {
  return window.localStorage.getItem('username')
}
